import Mock from 'mockjs'
import loginAPI from './demo/login'
import demoAPI from './demo/demo'
import articleAPI from './demo/article'
import remoteSearchAPI from './demo/remoteSearch'
import transactionAPI from './demo/transaction'

Mock.setup({
  timeout: '350-600'
})
// .mock(rurl,method,return);
// 其中rurl 是由 /regexp()/两个正斜杆包裹的正则表达式，表达式中出现的路径/都要用转移符号 \/
// 登录相关
Mock.mock(/\/web\/account\/login/, 'post', loginAPI.loginByUsername)
Mock.mock(/\/web\/account\/logout/, 'post', loginAPI.logout)
Mock.mock(/\/web\/user\/info\.*/, 'get', loginAPI.getUserInfo)

// 演示模块
Mock.mock(/\/demo\/helloworld!search/, 'post', demoAPI.search)
Mock.mock(/\/demo\/helloworld/, 'post', demoAPI.create)
Mock.mock(/\/demo\/helloworld/, 'patch', demoAPI.update)
Mock.mock(/\/demo\/helloworld/, 'delete', demoAPI.remove)
Mock.mock(/\/demo\/helloworlds/, 'delete', demoAPI.remove)

// 文章相关
Mock.mock(/\/article\/list/, 'get', articleAPI.getList)
Mock.mock(/\/article\/detail/, 'get', articleAPI.getArticle)
Mock.mock(/\/article\/pv/, 'get', articleAPI.getPv)
Mock.mock(/\/article\/create/, 'post', articleAPI.createArticle)
Mock.mock(/\/article\/update/, 'post', articleAPI.updateArticle)

// 搜索相关
Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser)

// 账单相关
Mock.mock(/\/transaction\/list/, 'get', transactionAPI.getList)

export default Mock
